import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { feedUserDefaultProps } from './defaultProps';
import type { FeedUserOptions } from './type';

export interface FeedUserProps extends FeedUserOptions, HTMLAttributes<HTMLElement> {}

const FeedUser: FC<FeedUserProps> = (props) => {
  const { className, as, children, forwardedRef, ...feedUserProps } = props;

  return createElement(
    as!,
    { ref: forwardedRef, className: classNames('user', className), ...feedUserProps },
    children,
  );
};

FeedUser.displayName = 'FeedUser';
FeedUser.defaultProps = feedUserDefaultProps;

export default FeedUser;
